<!DOCTYPE html>
<?php
$zhuti="defa";
if(isset($_COOKIE["zhuti"])){
    $zhuti=$_COOKIE["zhuti"];
}
echo "<br/>count(\$_POST)的长度:". count($_POST)."<br/>";
if(count($_POST)){
    $shuti=$_POST["zhuti"];
    setcookie("zhuti",$_POST["zhuti"],time()+3600*24*30);
}
?>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/Project/PHP/PHPProject.php to edit this template
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            .redl{
                background-color: red;
                color: yellow;
            }
            .bluel{
                background-color: blue;
                color: gray;
            }
            .defa{
                color: #005678;
            }
        </style>
    </head>
    <body class="<?php echo $zhuti;?>">
        <form action="index.php" method="post">
            <select name="zhuti">
                <option value="bluel">蓝色</option>
                <option value="redl">红色</option>
                
            </select>
            <br/>
            <input type="submit" value="确定"/>
            <p>
                cookie的使用案例
            </p>
        </form>
    </body>
</html>
